import { reqCategoryList } from "@/api/index.js";
import { reqbannerList } from "@/api/index.js";
import { reqfloorList } from "@/api/index.js";

const state = {
  categoryList: [],
  getBannerList: [],
  getFloorList: [],
};

const mutations = {
  CATEGORYLIST(state, categoryList) {
    state.categoryList = categoryList;
  },
  GETBANNERLIST(state, getBannerList) {
    state.getBannerList = getBannerList;
  },
  GETFLOORLIST(state, getFloorList) {
    state.getFloorList = getFloorList;
  },
};
const actions = {
  //通过API里面的接口函数调用，向服务器发请求，获取服务器的数据
  async categoryList({ commit }) {
    let result = await reqCategoryList();

    if (result.code == 200) {
      commit("CATEGORYLIST", result.data);
    }
  },
  async getBannerList({ commit }) {
    let result1 = await reqbannerList();
    if (result1.code == 200) {
      commit("GETBANNERLIST", result1.data);
    }
  },
  async getFloorList({ commit }) {
    let result = await reqfloorList();
    if (result.code == 200) {
      commit("GETFLOORLIST", result.data);
    }
  },
};
const getters = {};
export default {
  state,
  mutations,
  actions,
  getters,
};
